package cn.iocoder.yudao.module.member.alliance.mq;

import cn.hutool.extra.spring.SpringUtil;
import cn.iocoder.yudao.module.api.member.alliance.message.CloudAllianceAuditPassMessage;
import cn.iocoder.yudao.module.api.member.alliance.message.CloudAllianceOrderPaidMessage;
import cn.iocoder.yudao.module.api.member.alliance.message.CloudAllianceUserExpiredMessage;
import cn.iocoder.yudao.module.api.member.alliance.vo.CloudAllianceApplyVO;
import cn.iocoder.yudao.module.api.member.alliance.vo.CloudAllianceOrderVO;
import cn.iocoder.yudao.module.api.member.vip.message.VipUserExpiredMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * 云盟商 事件生产者
 *
 * @author 山野羡民
 */
@Component
@Slf4j
public class CloudAllianceProducer {

    /**
     * 发送 {@link CloudAllianceAuditPassMessage} 消息
     *
     * @param apply 招商人员申请信息
     */
    public void sendCloudAllianceAuditPassMessage(CloudAllianceApplyVO apply) {
        log.info("[sendCloudAllianceAuditPassMessage] ID#{}", apply.getId());
        SpringUtil.getApplicationContext().publishEvent(new CloudAllianceAuditPassMessage(apply));
    }

    /**
     * 发送 {@link CloudAllianceOrderPaidMessage} 消息
     *
     * @param order 交易订单信息
     */
    public void sendCloudAllianceOrderPaidMessage(CloudAllianceOrderVO order) {
        log.info("[sendCloudAllianceOrderPaidMessage] {}", order.getTradeNo());
        SpringUtil.getApplicationContext().publishEvent(new CloudAllianceOrderPaidMessage(order));
    }

    /**
     * 发送 {@link VipUserExpiredMessage} 消息
     *
     * @param userId 用户编号
     */
    public void sendCloudAllianceUserExpiredMessage(Long userId) {
        log.info("[sendCloudAllianceUserExpiredMessage] {}", userId);
        SpringUtil.getApplicationContext().publishEvent(new CloudAllianceUserExpiredMessage(userId));
    }

}
